package com.wxmit.framework.quartz.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wxmit.base.domain.ApiResult;
import com.wxmit.framework.quartz.domain.SysJob;
import com.wxmit.framework.quartz.domain.SysJobLog;
import com.wxmit.framework.quartz.service.ISysJobLogService;
import com.wxmit.framework.web.operatelog.Log;
import com.wxmit.framework.web.operatelog.LogModule;
import com.wxmit.framework.web.operatelog.enums.BusinessType;
import com.wxmit.system.base.core.ShushanBaseController;
import com.wxmit.system.base.domain.PageDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 调度日志操作处理
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/monitor/jobLog")
public class SysJobLogController
{
    @Autowired
    private ISysJobLogService jobLogService;

    /**
     * 查询定时任务调度日志列表
     */
    @PostMapping("/list")
    public IPage<SysJobLog> list(@RequestBody PageDTO<SysJobLog> pageDTO)
    {
        return jobLogService.selectJobLogList(pageDTO.getPage(),pageDTO.getSearchData());
    }

    
    /**
     * 根据调度编号获取详细信息
     */
    @GetMapping(value = "/{configId}")
    public SysJobLog getInfo(@PathVariable Long jobLogId)
    {
        return jobLogService.selectJobLogById(jobLogId);
    }


    /**
     * 删除定时任务调度日志
     */
    @Log(module = "定时任务",name = "清空定时任务日志",type = BusinessType.DELETE)
    @DeleteMapping("/{jobLogIds}")
    public ApiResult remove(@PathVariable Long[] jobLogIds)
    {
        return ApiResult.successWithData(jobLogService.deleteJobLogByIds(jobLogIds));
    }

    /**
     * 清空定时任务调度日志
     */
    @Log(module = "定时任务",name = "清空定时任务日志",type = BusinessType.DELETE)
    @DeleteMapping("/clean")
    public ApiResult clean()
    {
        jobLogService.cleanJobLog();
        return ApiResult.success();
    }
}
